\fc0 A REAL window is a PostScript window. Your check for a non-nil window assures that you have a AppKit-side window, but it doesn't check to make sure there is an associated PostScript window. When you grab a window in InterfaceBuilder, it is deferred by default. When a window is deferred the associated PostScript window won't be created until you actually bring that window on screen. You cannot draw to a window which doesn't yet have a PostScript window. You can change the deferred status using the “Deferred” switch button on the InterfaceBuilder Window inspector or with the proper argument to the Window method (
\b initContent:style:backing:buttonMask:defer:
\b0 ). If you're ever in doubt about a view's status, you can use the
\b canDraw
\b0 method which returns a boolean which indicates whether you are able to draw to that view.\